package com.itheima.health.controller.admin;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.result.PageResult;
import com.itheima.health.result.QueryPageBean;
import com.itheima.health.result.Result;
import com.itheima.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/setmeal")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    @GetMapping("findPage")
    public Result page(QueryPageBean queryPageBean){
        PageResult pageResult = setmealService.page(queryPageBean);
        return new Result(true, MessageConst.ACTION_SUCCESS,pageResult);
    }

    /**
     * 新增
     * @param setmeal
     * @param checkgroupIds
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody Setmeal setmeal,Integer[] checkgroupIds){
        setmealService.add(setmeal,checkgroupIds);
        return new Result(true,MessageConst.ADD_SETMEAL_SUCCESS);
    }

}
